#include <stdio.h>
#include <stdlib.h>

int* twoSum(int* nums, int numsSize, int target) {
    int* result = (int*)malloc(2 * sizeof(int));
    int i, j;
    for (i = 0; i < numsSize - 1; i++) {
        for (j = i + 1; j < numsSize; j++) {
            if (nums[i] + nums[j] == target) {
                result[0] = i;
                result[1] = j;
                return result;
            }
        }
    }
    free(result);
    return NULL;
}

int main() {
    int nums[] = {2, 7, 11, 15};
    int target = 9;
    int* result = twoSum(nums, sizeof(nums) / sizeof(int), target);
    if (result != NULL) {
        printf("这两个数的下标分别为：%d 和 %d\n", result[0], result[1]);
    } else {
        printf("找不到和为 %d 的两个数\n", target);
    }
    return 0;
}
